import { request } from '@/utils/http';

const ADD = '/app/activity/add';
const LIST = '/app/activity/list';
const ALL = '/app/activity/all';
const DELETE = '/app/activity/delete';
const DETAIL = '/app/activity/detail';
const PUT = '/app/activity/put';
const JOIN = '/app/activity/join';

/**
 * @param data 创建活动参数
 * @returns
 */
export function addActivity(data: ActivityModel) {
  return request.post<API>(ADD, data, {
    custom: {
      auth: true,
    },
  });
}
/**
 * @param {object} data pageSize,pageIndex分页参数
 * @returns
 */
export function allActivity(data: any) {
  return request.get<API>(ALL, data, {
    custom: {
      auth: true,
    },
  });
}
/**
 * @param {object} data pageSize,pageIndex分页参数
 * @returns
 */
export function listActivity(data: any) {
  return request.get<API>(LIST, data, {
    custom: {
      auth: true,
    },
  });
}
/**
 * @param data ids,删除活动参数
 * @returns
 */
export function deleteActivity(data: ActivityModel) {
  return request.delete<API>(DELETE, data, {
    custom: {
      auth: true,
    },
  });
}
/**
 * @param data 详情活动id
 * @returns
 */
export function detailActivity(data: number) {
  return request.get<API>(
    DETAIL + '/' + data,
    {},
    {
      custom: {
        auth: true,
      },
    },
  );
}
/**
 * @param data 修改活动参数
 * @returns
 */
export function putActivity(data: ActivityModel) {
  return request.put<API>(PUT, data, {
    custom: {
      auth: true,
    },
  });
}

/**
 *
 * @param id
 * @returns
 */
export function joinActivity(id: number) {
  return request.post<API>(
    JOIN,
    { id },
    {
      withCredentials: true,
    },
  );
}
